package builder

type Person struct {
	name, address, gender       string
	age                         int
	companyName, companyAddress string
}

func (p *Person) Name() string {
	return p.name
}

func (p *Person) Address() string {
	return p.address
}

func (p *Person) Gender() string {
	return p.gender
}

func (p *Person) Age() int {
	return p.age
}

func (p *Person) CompanyAddress() string {
	return p.companyAddress
}

func (p *Person) CompanyName() string {
	return p.companyName
}

type PersonBuilder struct {
	person *Person
}

func (b *PersonBuilder) Lives() *PersonAddressBuilder {
	return &PersonAddressBuilder{*b}
}

func (b *PersonBuilder) Works() *PersonJobBuilder {
	return &PersonJobBuilder{*b}
}

func (b *PersonBuilder) build() *Person {
	return b.person
}

func NewPersonBuilder() *PersonBuilder {
	return &PersonBuilder{person: &Person{}}
}

type PersonAddressBuilder struct {
	PersonBuilder
}

func (p *PersonAddressBuilder) SetName(name string) *PersonAddressBuilder {
	p.person.name = name
	return p
}

func (p *PersonAddressBuilder) SetAddress(address string) *PersonAddressBuilder {
	p.person.address = address
	return p
}

func (p *PersonAddressBuilder) SetGender(gender string) *PersonAddressBuilder {
	p.person.gender = gender
	return p
}

func (p *PersonAddressBuilder) SetAge(age int) *PersonAddressBuilder {
	p.person.age = age
	return p
}

type PersonJobBuilder struct {
	PersonBuilder
}

func (b *PersonJobBuilder) SetCompanyName(companyName string) *PersonJobBuilder {
	b.person.companyName = companyName
	return b
}

func (b *PersonJobBuilder) SetCompanyAddress(companyAddress string) *PersonJobBuilder {
	b.person.companyAddress = companyAddress
	return b
}
